home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 17692 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.8 KB

  1. Path: newsserver.rdcs.Kodak.COM!usenet
  2. From: Roman Fietze <fietze@ag01.kodak.COM>
  3. Newsgroups: comp.object,comp.lang.c++,comp.realtime,comp.dcom.telecom.tech,comp.arch.embedded
  4. Subject: Re: Can OO be successful in real-time embedded systems?
  5. Date: Wed, 17 Apr 1996 09:13:43 +0200
  6. Organization: Kodak AG Germany, OI PE&D
  7. Message-ID: <31749A27.3949@ag01.kodak.COM>
  8. References: <316BF0C5.1FE1@condat.de> <RMARTIN.96Apr11113222@rcm.oma.com>
  9.         <4kjfrh$28g@Starbase.NeoSoft.COM> <RMARTIN.96Apr16161415@rcm.oma.com>
  10. NNTP-Posting-Host: kagcpd10.ag01.kodak.com
  11. Mime-Version: 1.0
  12. Content-Type: text/plain; charset=us-ascii
  13. Content-Transfer-Encoding: 7bit
  14. X-Mailer: Mozilla 2.01 (X11; I; HP-UX A.09.05 9000/715)
  15.  
  16. Robert C. Martin wrote:
  17. > There is nothing about C++ that encourages programmers to perform
  18. > a great deal more allocation and de-allocation of memory.  Some
  19. > popular styles advocate this, but they advocate it in C++ as well as
  20. > other languages.
  21. > Also.  If you use a programming style that is heavily weighted towards
  22. > dynamic memory allocation, you can prefent fragmentation and heap
  23. > delays by using non-deterministic heaps.
  24.  
  25. If you really want to use the powers of C++ instead of using C++ as a
  26. better C you have more memory allocation and deallocation. In C you very
  27. often handle pointers and care about when to free the memory associated
  28. with that memory. In C++ you always copy memory to other objects with
  29. constructors or operators, because you use class objects like other
  30. integral types without thinking too much (you could, but you don't want
  31. to because the program is more readable then :). You even have a lot of
  32. memory allocation and deallocation by using arguments passed by value or
  33. by the compiler using temporaries. I was astonished, when I checked the
  34. code produced by my Microtec C++ 4.x, allthough when I thought about it,
  35. there was no other way to handle that.
  36.  
  37. In my special case I built a menu system based on an own curses
  38. implementation on pSOS. With the old C version I passed pointers to some
  39. structures to the menu library functions. In the C++ version I build a
  40. menu by adding menu items to a menu object, which causes many memory
  41. copy, allocation and deallocation calls (not to give the CPU any chance
  42. I even used a String class instead of char *'s). The other drawback is
  43. that with the old system I could hold the text for the menu text in ROM
  44. only (by declaring it const), but with C++ I have to copy it using e.g.
  45. the operator+= or some constructor, and even the type specifier const
  46. isn't a guarantee for beeing allocated in a readonly memory (ROM on
  47. embedded systems, readonly sections e.g. on UNIX), it just says, the
  48. variable cann only be initialized, but not changed by an assignement
  49. operator.
  50.  
  51. Roman
  52.  
  53. -- 
  54. Roman Fietze (Mail Code 5023)              Kodak AG Stuttgart/Germany
  55. http://www.kodak.com                                 fietze@kodak.COM
  56.